﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using Camc.Duct.Configuration;
using Camc.Duct.Web;

namespace Camc.Duct.EntityFrameworkCore
{
    /* This class is needed to run "dotnet ef ..." commands from command line on development. Not used anywhere else */
    public class SCDContextFactory : IDesignTimeDbContextFactory<SCDDbContext>
    {
        public SCDDbContext CreateDbContext(string[] args)
        {
            var builder = new DbContextOptionsBuilder<SCDDbContext>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

			//通过configuration无法读取配置参数
			SCDDbContextOptionsConfigurer.Configure(builder, "Server = 101.200.80.158; Database = DuctDb; Uid=sa;Pwd=tjhj123456,;");

            return new SCDDbContext(builder.Options);
        }

	}
}